<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>搜索详情</title>
    <link rel="stylesheet" href="css/public.css">
    <link rel="stylesheet" href="css/list.css">
    <script src="js/rem.js"></script>
</head>

<body>
    <div id="app">
        <div class="home" @click="home"><i href="javascript:;" class="back_ico"></i><span>主页</span></div>
        <div class="top">
            <img :src="list.albums" alt="">
        </div>
        <div class="title">
            <h1>{{list.title}}</h1>
            <p>{{list.tags}}</p>
        </div>
        <div class="imtro">
            <h3>彩蛋</h3>
            <p>{{list.imtro}}
            </p>
        </div>
        <div class="cailiao">
            <h3>所需材料</h3>
            <p>{{list.ingredients}}</p>
        </div>
        <div class="step">
            <h1>步骤</h1>
            <ul>
                <li v-for="(item, index) in listSteps" :key="index"> 
                    <p>{{item.step}}</p>
                    <img :src="item.img" alt="">
                </li>
            </ul>
        </div>
    </div>
    <script src="js/vue.js"></script>
    <script src="js/vue-resource.js"></script>
    <script>
        var Vm = new Vue({
            el: "#app",
            data: {
                url:"http://apis.juhe.cn/cook/queryid",
                key:"f25836940c8c65d4021f569c21e8e1dd",
                list:[],
                listSteps:[]
            },
            mounted() {
                this.getUrl()
            },
            methods: {
                //获取url
                getUrl:function(){
                    var data = decodeURI(location.href).split('?')[1].split('=')[1];
                    this.$http.jsonp(this.url + '?key=' + this.key + '&id='+data).then(function(res){
                        this.list = res.body.result.data[0];
                        this.listSteps = res.body.result.data[0].steps;
                        console.log(this.listSteps);
                        
                    })
                    
                },
                home:function(){
                    location.href = "index.html"
                },
            },
        })
    </script>
</body>

</html>